package br.com.lazyprogrammer.spaceshooter.model;

import br.com.lazyprogrammer.spaceshooter.model.listener.CollisionListener;
import br.com.limaogames.framework.model.DynamicGameObject;

/**
 * Created by LimaoGames on 19/8/2014.
 */
public class Player extends DynamicGameObject implements CollisionListener {

    public static final float PLAYER_MOVE_VELOCITY = 20;

    public static final float SHIP_WIDTH = 1.5f;
    public static final float SHIP_HEIGHT = 1.0f;

    public int healthBar;
    float stateTime;
    public float angle = 90;

    public Player(float x, float y) {
        super(x, y, SHIP_WIDTH, SHIP_HEIGHT);

        stateTime = 0;
        healthBar = 20;
        velocity.set(0, 0);
    }

    public void update(float deltaTime) {
        if (angle > 360)
            angle = 0;
        if (angle < 0)
            angle = 360;
        position.add(velocity.x * deltaTime, velocity.y * deltaTime);
        bounds.lowerLeft.set(position).sub(bounds.width / 2, bounds.height / 2);
    }

    @Override
    public void hit(int damage) {
        healthBar -= damage;
    }
}
